package com.lagou.ex.docker.controller;

import com.lagou.ex.docker.entity.Tbuser;
import com.lagou.ex.docker.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping("/users")
    public List<Tbuser> queryUsers() {
        return this.userService.queryUsers();
    }

    @RequestMapping(value = "/update")
    public Integer updateUser(Tbuser user) {
        userService.updateUser(user);
        return 1;
    }

    @RequestMapping(value = "/delete/{id}")
    public Integer deleteUser(@PathVariable Integer id) {
        userService.deleteUser(id);
        return 1;
    }

    @RequestMapping(value = "/save")
    public Integer saveUser(Tbuser user) {
        userService.saveUser(user);
        return 1;
    }

}
